﻿using System;
using System.Xml;
using System.Xml.Serialization;
using rlTodayMakeSkin.Project.Attributes;
using System.Drawing;

namespace rlTodayMakeSkin.Project.XmlElement
{
    /// <summary>
    /// Abstract class for Calendar and CalendarHeader xml element
    /// </summary>
    abstract public class rlAbstractCalendar : ContainerSubElements
    {
        private Color colore;
        private int intMonthOffset;

        /******************
         CONSTRUCTORS
         ******************/
        public rlAbstractCalendar(XmlNode n, rlTodayProject p)
            : base(n, p)
        {
            if (listaAtt["color"] != null) colore = GetColorFromRGB(listaAtt["color"].Value);
            if (listaAtt["offset"] != null) intMonthOffset = int.Parse(listaAtt["offset"].Value);
        }

        public rlAbstractCalendar(rlTodayProject p) : base(p) { }

        protected rlAbstractCalendar() { }

        /// <summary>
        /// Gets, sets color of calendar
        /// </summary>
        [PropertyDescription("Gets, sets color of calendar", PropertyTypes.COLOR)]
        [XmlIgnore()]
        public Color CalendarColor
        {
            get { return colore; }
            set { colore = value; }
        }

        /// <summary>
        /// Returns a string that represents RGB value of the Calendar color
        /// </summary>
        [PropertyDescription("RGB value of the Calendar color", ReadOnlyProperty=true)]
        [XmlAttribute("color")]
        public string RGBCalendarColor
        {
            get { return GetRGBFromColor(colore); }
        }

        /// <summary>
        /// Gets, sets month offset
        /// </summary>
        [PropertyDescription("Gets, sets month offset", PropertyTypes.INTEGER)]
        [XmlAttribute("offset")]
        public int MonthOffset
        {
            get { return intMonthOffset; }
            set { intMonthOffset = value; }
        }

    }
}
